package org.jtzc.chat.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * @author wu chuang
 * @description
 */
@RestController
public class ChatStreamController {
    @Autowired
    private ChatClient chatClient;
    @GetMapping(value = "/chatStream", produces = "text/html;charSet=utf-8")
    public Flux<String> stream(@RequestParam(value = "message", defaultValue = "hello") String message) {
        return chatClient.prompt().user(message).stream().content();
    }

}
